﻿package mortal.game.view.common.item
{
    import com.mui.controls.*;
    import com.mui.core.*;
    import flash.display.*;
    import flash.text.*;
    import mortal.common.*;
    import mortal.common.font.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;

    public class MoneyItem extends GSprite
    {
        protected var _tfNum:GTextFiled;
        protected var _bmpType:Bitmap;
        private var _unit:int;
        private var _value:int;

        public function MoneyItem()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            var _loc_1:* = new GTextFormat(FontUtil.defaultName, 12, 15859633);
            _loc_1.align = TextFormatAlign.RIGHT;
            this._tfNum = UIFactory.textField("", -80, 0, 80, 22, this, _loc_1);
            this._bmpType = UIFactory.bitmap(ImagesConst.Jinbi, 0, 6, this);
            this.updateMoneyBmpPos();
            return;
        }// end function

        public function set unit(param1:int) : void
        {
            this._unit = param1;
            this._bmpType.bitmapData = GlobalClass.getBitmapData(GameDefConfig.instance.getEPrictUnitImg(param1));
            this.updateMoneyBmpPos();
            return;
        }// end function

        public function get unit() : int
        {
            return this._unit;
        }// end function

        public function set value(param1:int) : void
        {
            this._value = param1;
            this._tfNum.htmlText = param1.toString();
            return;
        }// end function

        public function get value() : int
        {
            return this._value;
        }// end function

        public function update(param1:int, param2:int) : void
        {
            this._tfNum.text = param1.toString();
            this._bmpType.bitmapData = GlobalClass.getBitmapData(GameDefConfig.instance.getEPrictUnitImg(param2));
            this.updateMoneyBmpPos();
            return;
        }// end function

        public function updateMoneyBmpPos() : void
        {
            var _loc_1:* = this._tfNum;
            this._bmpType.x = _loc_1.x + _loc_1.width + 3;
            this._bmpType.y = _loc_1.y + (_loc_1.height - this._bmpType.height) / 2;
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this._tfNum.dispose(param1);
            UIFactory.disposeBitmap(this._bmpType, param1);
            this._tfNum = null;
            this._bmpType = null;
            super.disposeImpl(param1);
            return;
        }// end function

        public function get bmpType() : Bitmap
        {
            return this._bmpType;
        }// end function

        public function get tfNum() : GTextFiled
        {
            return this._tfNum;
        }// end function

    }
}
